/**
 * 
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.TopicDAO;
import com.sesame.domain.Topic;

/**
 * @author voidman
 * 
 */
public class TopicDAOImpl extends SqlMapClientDaoSupport implements TopicDAO {

    public void addTopic(Topic Topic) {
        getSqlMapClientTemplate().insert("addTopic", Topic);
    }

    public void deleteTopicById(Integer id) {
        getSqlMapClientTemplate().delete("deleteTopicById", id);
    }

    @SuppressWarnings("unchecked")
    public List<Topic> getAllTopic() {
        List<Topic> listTopic;
        listTopic = getSqlMapClientTemplate().queryForList("getAllTopic");
        return listTopic;
    }

    public Topic getTopicByNickName(String nickName) {
        return (Topic) getSqlMapClientTemplate().queryForObject("getTopicByNickName", nickName);
    }

    public void updateTopic(Topic Topic) {
        getSqlMapClientTemplate().update("updateTopic", Topic);
    }

    public void deleteTopicByNickName(String nickName) {

        getSqlMapClientTemplate().delete("deleteTopicByNickName", nickName);
    }

}
